﻿using AllInOnePluginBL.Helpers;
using PluginDB;
using NLog;
 

namespace AllInOnePluginBL.Rules
{
    /// <summary>
    /// Summary description for VerifyBrokenLinkRule
    /// </summary>
    public class VerifyBrokenLinkRule : IRule
    {
        private readonly Logger _log = LogManager.GetLogger("VerifyBrokenLinkRule");

        public void ApplyRule(PluginVideoInfo pluginVideoInfo)
        {
            foreach (var link in pluginVideoInfo.Links)
            {
                string errorText;
                link.IsBrokenLink = Utils.IsBrokenLink(link.LinkURL, out errorText);
                if(link.IsBrokenLink)
                    _log.Debug("Link is not valid: Link[{0}], Error: {1}", link.LinkURL, errorText);
            }
        }
    }
}